"""
@title(TenX腾晓2024年12月考核答题文件)
@warning(请勿修改参数和返回值)
@warning(请认真填写__init__中的数据)
@author(1323230180)
@license(CC BY-SA 4.0 License)
"""
import os
from copy import deepcopy


class TenXClass:
    def __init__(self):
        # 获取当前文件名并截取文件名的学号-姓名
        file_name = os.path.basename(__file__).split('.')[0].split("-")
        self.id = '3124002010'  # 学号
        self.name = '江泽林'  # 姓名

    @staticmethod
    def question1(*args) -> list[str]:
        binary_tree = deepcopy(args[0])  # 传入的地牢结构（二叉树），详细请看BinaryTree.py



        def find_the_zero(root):
            paths = []

            def helper(node, path):
                if not node:
                    return
                path.append(node.value)  # 将当前节点的值node.val添加到列表path中
                if node.value == 0 and node.left is None and node.right is None:
                    paths.append(path[:])  # 说明找到了正确的节点，将path中的节点'切片'保存到paths中
                helper(node.left, path)  # 对左右子树进行递归
                helper(node.right, path)
                path.pop()  # 搜索完后直接删除此路径最后一个，回溯后继续搜索

            helper(root, [])
            return paths

        a1 = find_the_zero(binary_tree.root)
        b1 = []
        for i in a1:
            c1 = "".join(str(j) for j in i)
            b1.append(c1)
        return b1

    @staticmethod
    def question2(*args) -> str:
        matrix = deepcopy(args[0])  # 传入的河流结构（矩阵）
        d1 = []
        for i in matrix:
            d1.append(str(max(i)))
        e1 = ''.join(d1)
        return e1

    @staticmethod
    def question3(*args) -> int:
        f1 = 6 * 7 ** 999 - 5 * 6 ** 999
        return f1 % 99999999

    @staticmethod
    def question4(*args) -> int:
        n = deepcopy(args[0])  # 用于搭建金字塔的球个数

        m = 0
        for k in range(1, n):
            if k * (k + 1) * (k + 2) / 6 <= n < (k + 1) * (k + 2) * (k + 3) / 6:
                m += k
                break

        return m

    @staticmethod
    def question5(*args) -> list[str]:
        balls = deepcopy(args[0])  # 五行空间球的初始值

        list1 = []
        for y in balls:
            list1.append(y)
        num1 = 5
        test_list = []
        while len(test_list) < 5:
            for x in list1:
                if x >= 10000:
                    test_list.append(x)
                else:
                    list1[num1 % 5] = list1[(num1 - 1) % 5] + list1[(num1 - 2) % 5]
                    num1 += 1
        else:
            for z in range(0, len(list1)):
                list1[z] = str(list1[z])

        return list1